<?php
class MSEP_Messages extends MSEP_Object
{


      public $error;



      private $messages;



      public function __init(MSEP $core)
      {
            $this->core = $core;

            $this->core->__('smarty')->assign('msep_error', 0);

            $this->core->__('smarty')->assign('msep_msg', '');

            $this->error = 0;
      }



      public function success($msg_id = "", $msg_args = array())
      {
            $this->core->__('smarty')->assign('msep_error', 0);

            $this->error = 0;

            $this->set_message($msg_id, $msg_args);
      }



      public function failure($msg_id = "", $msg_args = array())
      {
            $this->core->__('smarty')->assign('msep_error', 1);

            $this->error = 1;

            $this->set_message($msg_id, $msg_args);
      }



      private function set_message($msg_id = "", $msg_args = array())
      {
            if ($msg_id != "")
            {
                  $messages = $this->core->__('messages');

                  if (empty($msg_args))
                  {
                        $this->core->__('smarty')->assign('msep_msg', SE_Language::_get($messages[$msg_id]));
                  }
                  else
                  {
                        $this->core->__('smarty')->assign('msep_msg', SE_Language::get($messages[$msg_id], $msg_args));
                  }
            }
      }


}
?>